<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>vue.js 学习</title>

    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        {{message}} <br>
        <span v-bind:title="title">
            鼠标悬停几秒钟查看此处动态绑定的提示信息！
        </span>
        <div>
            条件与循环
            <p v-if="seen">我看见了</p>
            <p v-for="(item, index) in todolist" :key="index">{{item}} > {{index}}</p>
        </div>
        <div>
            <a :href="baidu">hello btn</a>
            <button @click="hello">hello</button>
            <p>{{dynamicMsg}}</p>
            <p>this is master branch</p>
        </div>
    </div>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue!',
                title: '页面加载于 ' + new Date().toLocaleString(),
                seen: true,
                todolist: ['item1', 'item2', 'item3'],
                baidu: 'http://www.baidu.com'
            },
            computed: {
                dynamicMsg: function() {
                    return this.message.split('').reverse().join('');
                }
            },
            watch: {
                message: function(val) {
                    console.log('message new value', val);
                }
            },
            created() {
                console.error('created called');
            },
            methods: {
                hello() {
                    alert('hello called');
                }
            },
        })
    </script>
</body>
</html>